API Docs for: 最后更新日期:2014年8月25日
Google搜索   
Show:

Global Functions Class

Defined in: main/Function.js:1

Available since 1.0.0

Methods

addChild

(
  • expression
)
public

Defined in main/Function.js:188

Available since 1.0.0

Adds a child DisplayObject instance to the Stage.

Parameters:

  • expression Object

    The DisplayObject instance that you pass in the child parameter.

Example:

var backLayer = LSprite();
addChild(backLayer);

getTimer

() Float public

Defined in main/Function.js:326

Available since 1.0.0

Returns the number of milliseconds that have elapsed since Engine initialization.

Returns:

Float:

The number of milliseconds that have elapsed since Engine initialization.

LExtends

(
  • child
  • parent
  • params
)
public

Defined in main/Function.js:276

Available since 1.0.0

Object Inheritance.Equivalent to base.

Parameters:

  • child LDisplayObject

    The child。

  • parent Object

    The parent。

  • params Array

    params。

Example:

LInit(50, "legend", 800, 480, main);
function FatherClass(){
    this.name = "Father";
}
FatherClass.prototype.getName = function(){
    return this.name;
};
function ChildClass(){
    LExtends(this,FatherClass,[]);
    this.name = "Child";
}
function main () {
    LGlobal.setDebug(true);
    var father = new FatherClass();
    var child = new ChildClass();
    trace("father.getName() = " + father.getName()); //father.getName() = Father
    trace("child.getName() = " + child.getName());//child.getName() = Child
}

LInit

(
  • speed
  • divid
  • width
  • height
  • callback
  • type
)
public

Defined in main/Function.js:215

Available since 1.0.0

Engine initialization. Equivalent to init.

Parameters:

  • speed Float

    game speed(milliseconds), FPS = 1000 / speed.

  • divid String

    Specifies a unique id for a div tag.

  • width Int

    Game Interface's width.

  • height Int

    Game Interface's height.

  • callback Function

    Engine initialization's callback method.

  • type String

    If your init function call is after the onload, then you need to set this parameter to LEvent.INIT.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<div id="mylegend">loading……</div>
<script type="text/javascript" src="../lufylegend-x.x.x.min.js"></script> 
<script>
LInit(50,"mylegend",800,480,main);
//window.onload = function(){LInit(50, "mylegend", 800, 480, main, LEvent.INIT);};
function main(){
    alert("Hello lufylegend!");
}
</script>
</body>
</html>

removeChild

(
  • expression
)
public

Defined in main/Function.js:201

Available since 1.0.0

Removes the specified child DisplayObject instance from the child list of the Stage instance.

Parameters:

  • expression Object

    The DisplayObject instance to remove.

Example:

var backLayer = LSprite();
addChild(backLayer);
removeChild(backLayer);

trace

(
  • expression
)
public

Defined in main/Function.js:161

Available since 1.0.0

You can use Debug Mode to capture output from the trace() function and display the result. If any argument in a trace statement includes a data type other than a String, the trace function invokes the associated toString() method for that data type. For example, if the argument is a Boolean value the trace function invokes Boolean.toString() and displays the return value.

Parameters:

  • expression Object

    An expression to evaluate. the value of the expression parameter is displayed in the Output panel.

Example:

trace("debug text 1", "debug text 2", "debug text 3");